<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <title>回收员</title>
        <link rel="stylesheet" href="<c:url value="/static/wx/css/style.css"/>" />
        <style type="text/css">
            body{background:#EFEFF4;}
        </style>
        <script type="text/javascript" src="<c:url value="/static/wx/js/lib/rem.js"/>" ></script>
    </head>
    <body class="befeff4">
        <div id="wrap">
            <div class="header_s mt10">
                <c:if test="${userVo.bId != null }">
                    <a href="<c:url value="/wx/toUser.do"/>?id=${userVo.bId}">
                        <%-- <img class="header_img" src="<c:url value="/static/wx/img/people.png"/>" /> --%>
                        <c:if test="${userVo.userImg == null }">
                            <img class="header_img" src="<c:url value="/static/wx/img/people.png"/>" />
                        </c:if>
                        <c:if test="${userVo.userImg != null }">
                            <img class="header_img" src="${userVo.userImg }">
                        </c:if>
                    </a>
                </c:if>
                
                <c:if test="${userVo.id != null }">
                    <a href="<c:url value="/wx/toUser.do"/>?id=${userVo.id}">
                        <%-- <img class="header_img" src="<c:url value="/static/wx/img/people.png"/>" /> --%>
                        <c:if test="${userVo.userImg == null }">
                            <img class="header_img" src="<c:url value="/static/wx/img/people.png"/>" />
                        </c:if>
                        <c:if test="${userVo.userImg != null }">
                            <img class="header_img" src="${userVo.userImg }">
                        </c:if>
                    </a>
                </c:if>
                <img class="star_img" src="<c:url value="/static/wx/img/srar_icon.png"/>" />
                <div class="order_text clearfix">
                    <span>今日接单量：${countNum } </span>
                    <c:if test="${totalPrice != null }">
                        <span>今日总金额：${totalPrice }元  </span>
                    </c:if>
                    <c:if test="${totalPrice == null }">
                        <span>今日总金额：0元  </span>
                    </c:if>
                </div>
            </div>
            
            <ul class="ul-tab-btn clearfix">
                <li class="w33 on"><a onclick="serchOrderList(1)">进行中</a><i></i></li>
                <li class="w33"><a onclick="serchOrderList(2)">已完成</a><i></i></li>
                <li class="w33"><a onclick="serchOrderList(3)">已取消</a><i></i></li>
            </ul>
            
            <div class="order_noData tc" id="no_list"></div>
            <div class="order_list" id="order_list"></div>
            
            <!--订单取消确定提示提示弹窗开始-->
            <div class="mask">
                <div class="toolTip_box">
                    <p class="toolTip_text f16">确定取消该订单吗？</p>
                    <a class="msg_cancel_btn">再等等</a><a class="msg_sure_btn">确定</a>
                </div>
            </div>
            <!--订单取消确定提示提示弹窗结束-->
            <!--订单取消下单成功提示弹窗开始-->
            <div class="msg-succ">
                <p class="f16">订单已取消</p>
            </div>
            <!--订单取消下单成功提示弹窗结束-->
        </div>
        <input type="hidden" id="receiptId" value="${userVo.bId }"/>
        <script type="text/javascript" src="<c:url value="/static/wx/js/lib/jquery-3.3.1.min.js"/>" ></script>
        <script>
            //首部导航切换
            $(".ul-tab-btn").on("click","li",function(){
                //选项卡按钮样式切换
                 $(this).addClass("on").siblings("li").removeClass("on");
            })
            //取消按钮
            $(".cancel_btn").on("click",function(){
                $(".mask").show();
            })
            $(".msg_cancel_btn").on("click",function(){
                $(".mask").hide();
            })
            function ifCancel(id) {
                $(".mask").show();
              //取消按钮
                $(".msg_sure_btn").on("click",function(){
                    $(".mask").hide();
                    var f = arguments.callee, self = this;
                    $(self).unbind('click', f);  
                    $.ajax({
                        type: "post",
                        url: "<c:url value="/wx/updateOrderStatus.do"/>",
                        data: {
                            bId : id,
                            status : 3
                        },
                        cache: true, 
                        async:false, 
                        dataType: "json",
                        success: function(data){
                            if (data.msg != null) {
                                $(".msg-succ").show();
                                setTimeout(hideTips, 3000);
                                serchOrderList(3);                    
                            }
                            $(self).click(f);
                        }
                    });
                })
            }
            
            function hideTips(){
                $(".msg-succ").hide();
            }
            
            $(document).ready(function(){
                serchOrderList(1);
            })
            
            var receiptId = $("#receiptId").val();
            function serchOrderList(status){
                $.ajax({
                    type: "post",
                    url: "<c:url value="/wx/serchReceiptOrderList.do"/>",
                    data: {
                        receiptId : receiptId,
                        status : status,
                        page : 1,
                        size : 99
                    },
                    cache: true, 
                    async:false, 
                    dataType: "json",
                    success: function(data){
                        var result = "";
                        if (data.wOrderVo.length>0) {
                            for (var i = 0 ; i<data.wOrderVo.length;i++) {
                                switch (data.wOrderVo[i].status) {
                                   case 1:
                                       result += '<ul class="ul-tab-content bn bf padding20 mt10">';
                                       result += '<li>预约 '+data.wOrderVo[i].pickTime+'</li>';
                                       result += '<li>'+data.wOrderVo[i].city+''+data.wOrderVo[i].area+''+data.wOrderVo[i].address+'</li>';
                                       result += '<li>'+data.wOrderVo[i].userContacts+'   '+data.wOrderVo[i].userTelephone+'</li>';
                                       for (var j = 0 ; j<data.wOrderVo[i].orderCategoryVos.length;j++) {
                                           result += '<li>'+data.wOrderVo[i].orderCategoryVos[j].name;
                                           result +=     data.wOrderVo[i].orderCategoryVos[j].weight;
                                           result += '</li>';
                                       }
                                       result += '<li class="boder-bottom mt20 mlr"></li>';
                                       result += '<li class="mt25 clearfix">';
                                       result += "<a href=\"<c:url value="/wx/toPriced.do"/>?id="+data.wOrderVo[i].bId+"\" class='price_btn fr'> 过磅定价</a>";
                                       result += '<a class="tel_btn blue_btn fr" href=tel:'+data.wOrderVo[i].userTelephone+'>致电用户</a>';
                                       result += "<a class='cancel_btn c999 w60 fr' onclick=\"ifCancel('"+data.wOrderVo[i].bId+"')\">取消</a>";
                                       result += '</li>';
                                       result += '</ul>';
                                       break;
                                   case 2:
                                       result += '<ul class="ul-tab-content bn bf padding20 mt10">';
                                       result += '<li>'+data.wOrderVo[i].pickTime+'';
                                       result += '<span class="c666">已完成</span>';
                                       result += '</li>';
                                       result += '<li>'+data.wOrderVo[i].city+''+data.wOrderVo[i].area+''+data.wOrderVo[i].address+'';
                                       result += '<span class="cff6633 fr">总计：'+data.wOrderVo[i].countPrice+'元</span>';
                                       result +='</li>';
                                       for (var j = 0 ; j<data.wOrderVo[i].orderCategoryVos.length;j++) {
                                           result += '<li>'+data.wOrderVo[i].orderCategoryVos[j].name;
                                           if (data.wOrderVo[i].orderCategoryVos[j].actualWeight != "") {
                                        	    result +=     data.wOrderVo[i].orderCategoryVos[j].actualWeight+'kg';
                                           }
                                           result += '</li>';
                                       }
                                        break;
                                    case 3:
                                        result += '<ul class="ul-tab-content bn bf padding20 mt10">';
                                        result += '<li>'+data.wOrderVo[i].pickTime+'';
                                        result += "<span class='c666' onclick=\"ifCancel('"+data.wOrderVo[i].bId+"')\">已取消</span>";
                                        result += '</li>';
                                        result += '<li>'+data.wOrderVo[i].city+''+data.wOrderVo[i].area+''+data.wOrderVo[i].address+'</li>';
                                           for (var j = 0 ; j<data.wOrderVo[i].orderCategoryVos.length;j++) {
                                               result += '<li>'+data.wOrderVo[i].orderCategoryVos[j].name;
                                               result +=    data.wOrderVo[i].orderCategoryVos[j].weight;
                                               result += '</li>';
                                           }
                                       break;
                                }
                                result += '</ul>';
                            }
                             $("#order_list").show();
                             $("#no_list").hide();
                             $("#order_list").html(result);
                        }else {
                            result += "";
                            result += "<img src=\"<c:url value="/static/wx/img/no_data.png"/>\" />";
                            result += '<p>暂无订单</p>';
                            $("#order_list").hide();
                            $("#no_list").show();
                            $("#no_list").html(result);
                        }
                    }
                })
            }
        </script>
    </body>
</html>
